
@echo off

set PROJECT_TITLE=xio
set PROJECT_VARIABLE=XIO_INCLUDE
set PROJECT_VARIABLE_VALUE=%XIO_INCLUDE%

SETLOCAL ENABLEEXTENSIONS
color 1e
cls

echo %PROJECT_TITLE% developers setup
echo.

set START_DIR=%CD%
set CURR_DIR=C:\

:START

set choice=
set /p choice=Do you want to start setup %PROJECT_TITLE%? [Y]es, [N]o 
if not "%choice%" == "" set choice=%choice:~0,1%
if "%choice%" == "Y" goto :BROWSE
if "%choice%" == "y" goto :BROWSE
if "%choice%" == "N" goto :END
if "%choice%" == "n" goto :END

goto START

rem Search for dependency folder...

:BROWSE

IF "%CURR_DIR%"=="%CD%" GOTO DIR_NOT_FOUND

set CURR_DIR=%CD%

cd ..

IF NOT EXIST %CD%\dependency\NUL GOTO BROWSE

rem Folder found, not set new value..

set VARIABLE=XGW_DEP
set VALUE=%CD%\dependency

rem -----------------------------------------
rem -- Set Enviroment variable for a user....
rem -----------------------------------------

:CHECK_PROJECT_INCLUDE

rem here we set header path of %PROJECT_TITLE%
echo Setting header path of %PROJECT_TITLE% [%PROJECT_VARIABLE%]...
echo.

IF "%PROJECT_VARIABLE_VALUE%" neq "" IF "%PROJECT_VARIABLE_VALUE%"=="%START_DIR%\include" GOTO CHECK_XGW_DEP

IF "%PROJECT_VARIABLE_VALUE%" neq "" echo Current %PROJECT_VARIABLE%=%PROJECT_VARIABLE_VALUE%
IF "%PROJECT_VARIABLE_VALUE%" neq "" echo New     %PROJECT_VARIABLE%=%START_DIR%\include
echo.

echo reg add HKCU\Environment /v %PROJECT_VARIABLE% /d "%START_DIR%\include"
echo.

reg add HKCU\Environment /v %PROJECT_VARIABLE% /d "%START_DIR%\include"

echo.

:CHECK_XGW_DEP

rem here we set dependency path for %PROJECT_TITLE%
echo Setting dependency path for %PROJECT_TITLE%...
echo.

IF "%XGW_DEP%" neq "" IF "%XGW_DEP%"=="%VALUE%" GOTO CHECK_DIR_XGW_DEP

IF "%XGW_DEP%" neq "" echo Current XGW_DEP=%XGW_DEP%
IF "%XGW_DEP%" neq "" echo New     XGW_DEP=%VALUE%
echo.

echo reg add HKCU\Environment /v %VARIABLE% /d "%VALUE%"
echo.

reg add HKCU\Environment /v %VARIABLE% /d "%VALUE%"

echo.


:CHECK_DIR_XGW_DEP
IF NOT EXIST %XGW_DEP%\NUL GOTO MK_DIR_XGWDEP

:CHECK_DIR_INCLUDE

IF NOT EXIST %XGW_DEP%\include\NUL GOTO MK_DIR_INCLUDE

:CHECK_DIR_LIB

IF NOT EXIST %XGW_DEP%\lib\NUL GOTO MK_DIR_LIB


:FINISH

echo.

goto END

rem -----------------------------------------
rem -- Set Enviroment variable for a user....
rem -----------------------------------------

:MK_DIR_XGWDEP

echo "%XGW_DEP%" not found, creating!
mkdir %XGW_DEP%

goto CHECK_DIR_INCLUDE

:MK_DIR_INCLUDE

echo "%XGW_DEP%\include" not found, creating!
mkdir %XGW_DEP%\include

goto CHECK_DIR_LIB

:MK_DIR_LIB

echo "%XGW_DEP%\lib" not found, creating!
mkdir %XGW_DEP%\lib

goto FINISH


:DIR_NOT_FOUND

echo Directory dependecy not found. XGW_DEP not set
echo.

goto END


:END

echo.

cd %START_DIR%

pause

color